package com.example.dllo.keepdemo.person;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.ImageLoader;
import com.example.dllo.keepdemo.R;
import com.example.dllo.keepdemo.person.bean.PersonShowBean;
import com.example.dllo.keepdemo.tools.VolleySingleton;

/**
 * Created by dllo on 16/1/22.
 */
public class PersonShowRecyclerViewAdapter extends RecyclerView.Adapter<PersonShowRecyclerViewAdapter.MyViewHolder> {
    private Context context;
    private PersonShowBean data;

    public PersonShowRecyclerViewAdapter(Context context,PersonShowBean data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_recyclerview_activity_presonshow,parent,false);
        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.textView.setText(data.getData().getAchievements().get(position).getAchievementName());
        ImageLoader.ImageListener listener = ImageLoader.getImageListener(holder.imageView,R.mipmap.placeholder41_41,R.mipmap.placeholder41_41);
        VolleySingleton.getImageLoader().get(data.getData().getAchievements().get(position).getPicture(),listener,110,110);
    }

    @Override
    public int getItemCount() {
        return data.getData().getAchievements().size();
    }


    class MyViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textView;
        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.img_item_activity_personshow_img);
            textView = (TextView) itemView.findViewById(R.id.tv_item_activity_personshow_text);
        }
    }
}
